// 1.Record
// 2.ReturnType

// 1.Record
// 约束对象的Key以及Value
// 所以接收两个泛型参数

/* // 原理
// 对象的key是string | number | symbol
type ObjKey = keyof any;  // type ObjKey = string | number | symbol
// type CustomRecord<K extends string | number | symbol, T> = {
//   [P in K]: T
// }

type CustomRecord<K extends ObjKey, T> = {
  [P in K]: T
}

type Key = 'c' | 'x' | 'k'          // key不能少
type Value = "唱歌" | "跳舞" | "rap" // value随便

let genericsRecord01: Record<Key, Record<Key, Value>> = {
  c: {
    c: "唱歌",
    x: "跳舞",
    k: "rap"
  },
  x: {
    c: "唱歌",
    x: "跳舞",
    k: "rap"
  },
  k: {
    c: "唱歌",
    x: "跳舞",
    k: "rap"
  }
} */


// 2.ReturnType
// 获取函数类型的返回值

// 原理
type CustomRecordType<F extends Function> = F extends (...args:any[]) => infer R ? R : never

const ReturnTypeFn = () => [1, 2, 3, 'dsadsa', false]
type arrType = CustomRecordType<typeof ReturnTypeFn>      // type arrType = (string | number | boolean)[]

/* const ReturnTypeFn = () => [1,2,3,'dsadsa',false]
type arrType = ReturnType<typeof ReturnTypeFn>      // type arrType = (string | number | boolean)[] */
